regex get only domain name from url

67

get domain name with regex -

const urls = [
  'www.abc.au.uk',
  'https://github.com',
  'http://github.ca',
  'https://www.google.ru',
  'http://www.google.co.uk',
  'www.yandex.com',
  'yandex.ru',
  'yandex',
  'devmaster.auxitaplatform.com',
]

urls.forEach(url => console.log(url.replace(/.+\/\/|www.|\..+/g, '')))

Comments

Submit
0 Comments